//
//  ComButtomBtn.m
//  ECO
//
//  Created by zl on 2019/9/29.
//  Copyright © 2019 谷银行. All rights reserved.
//

#import "ComButtomBtn.h"

@implementation ComButtomBtn
- (UIView *)link{
    if (!_link) {
        _link = [[UIView alloc]init];
        _link.backgroundColor = [UIColor colorWithHexString:@"#F6F6F6"];
    }
    return _link;
}
- (UIView *)CenterLink{
    if (!_CenterLink) {
        _CenterLink = [[UIView alloc]init];
        _CenterLink.backgroundColor = [UIColor colorWithHexString:@"#F6F6F6"];
    }
    return _CenterLink;
}
- (UIButton *)QxBtn{
    if (!_QxBtn) {
        _QxBtn = [[UIButton alloc]init];
        _QxBtn.backgroundColor = [UIColor whiteColor];
        [_QxBtn addTarget:self action:@selector(Qxbtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _QxBtn;
}
- (UIImageView *)imgVbtn{
    if (!_imgVbtn) {
        _imgVbtn = [[UIImageView alloc]init];
    }
    return _imgVbtn;
}
- (UILabel *)LabelBtn{
    if (!_LabelBtn) {
        _LabelBtn = [[UILabel alloc]init];
        _LabelBtn.text = @"全选";
        _LabelBtn.textColor = [UIColor colorWithHexString:@"#999999"];
    }
    return _LabelBtn;
}
- (UIButton *)ScBtn{
    if (!_ScBtn) {
        _ScBtn = [[UIButton alloc]init];
        _ScBtn.backgroundColor = [UIColor whiteColor];
        [_ScBtn setTitle:@"删除" forState:UIControlStateNormal];
        [_ScBtn setTitleColor:[UIColor colorWithHexString:@"#FF4F4F"] forState:UIControlStateNormal];
        [_ScBtn addTarget:self action:@selector(Scbtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _ScBtn;
}
- (instancetype)initWithFrame:(CGRect)frame{
    if (self == [super initWithFrame:frame]) {
        [self addSubview:self.link];
        [self addSubview:self.CenterLink];
        [self addSubview:self.QxBtn];
        [self addSubview:self.ScBtn];
        [self.QxBtn addSubview:self.imgVbtn];
        [self.QxBtn addSubview:self.LabelBtn];
        [self BtnFrame];
    }
    return self;
}
- (void)BtnFrame{
    [_link mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self);
        make.left.equalTo(self);
        make.right.equalTo(self);
        make.height.equalTo(@(1));
    }];
    [_QxBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self);
        make.width.equalTo(@((kScreenWidth - 0.5)/2));
        make.height.equalTo(@(46));
    }];
    [_CenterLink mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.link.mas_bottom);
        make.left.equalTo(self.QxBtn.mas_right);
        make.height.equalTo(@(48));
        make.width.equalTo(@(1));
    }];
    [_ScBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.equalTo(self.mas_right);
        make.width.equalTo(@((kScreenWidth - 0.5)/2));
        make.height.equalTo(@(46));
    }];
    [_imgVbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.QxBtn);
        make.left.equalTo(self.QxBtn).offset(70);
        make.width.height.equalTo(@(14));
    }];
    [_LabelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.QxBtn);
        make.left.equalTo(self.imgVbtn.mas_right).offset(5);
        make.width.equalTo(@(50));
        make.height.equalTo(@(21));
    }];
}
- (void)Qxbtn:(UIButton *)send{
    
    
    NSLog(@"全选");
    if (self.delegate && [self.delegate respondsToSelector:@selector(ComButtomBtnQxClick:)]) {
        [self.delegate performSelector:@selector(ComButtomBtnQxClick:) withObject:send];
    }
}
- (void)Scbtn:(UIButton *)send{
    NSLog(@"删除");
    if (self.delegate && [self.delegate respondsToSelector:@selector(ComButtomBtnScClick)]) {
        [self.delegate performSelector:@selector(ComButtomBtnScClick) withObject:nil];
    }
}
@end
